﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace OnLineExam.Web.Models.ExcelViewModels
{
    public static class ProblemViewModelExtensions
    {
        public static OnLineExam.Data.SingleProblem GetSingleProblem(this SingleProblemModel item, int paperId)
        {

            return new OnLineExam.Data.SingleProblem
            {
                Answer = item.Answer,
                AnswerA = item.A,
                AnswerB = item.B,
                AnswerC = item.C,
                AnswerD = item.D,
                PaperID = paperId,
                Title = item.Title,
            };
        }


        public static OnLineExam.Data.MultiProblem GetMultiProblem(this MultiProblemModel item, int paperId)
        {

            return new OnLineExam.Data.MultiProblem
            {
                Answer = item.Answer,
                AnswerA = item.A,
                AnswerB = item.B,
                AnswerC = item.C,
                AnswerD = item.D,
                PaperID = paperId,
                Title = item.Title, 
                AnswerE = item.E,
                AnswerF = item.F,
                AnswerG = item.G, 

            };
        }


        public static OnLineExam.Data.JudgeProblem GetJudgeProblem(this JudgeProblemModel item, int paperId)
        {

            return new OnLineExam.Data.JudgeProblem
            {
                Answer = item.Answer == "正确" ? true : false,

                PaperID = paperId,
                Title = item.Title,


            };
        }

        public static OnLineExam.Data.FillBlankProblem GetFillBlankProblem(this FillBlankProblemModel item, int paperId)
        {

            return new OnLineExam.Data.FillBlankProblem
            {
                Answer = item.Answer,
                BackTitle = item.BackTitle,
                FrontTitle = item.FrontTitle,
                PaperID = paperId,
                Title = item.Title,


            };
        }

        public static OnLineExam.Data.QuestionProblem GetQuestionProblem(this QuestionProblemModel item, int paperId)
        {

            return new OnLineExam.Data.QuestionProblem
            {
                Answer = item.Answer,

                PaperID = paperId,
                Title = item.Title,


            };
        }
    }
}